package com.test.work.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.test.work.dao.UserMapper;
import com.test.work.model.User;
import com.test.work.service.IUserService;

@Service
public class UserService implements IUserService {

	@Resource
	private UserMapper userDao;
	
	@Override
	public Object login(String username, String password) throws Exception {
		Integer i = 0;
		i = userDao.login(username,password);
		if(i==null)
			return 0;
		else
			return 1;
	}

	@Override
	public Object register(String username, String password) throws Exception {
		Integer i = userDao.chachong(username);
		if(i == null){
			User record = new User();
			record.setUsername(username);
			record.setPassword(password);
			record.setIsDelete(1);
			userDao.insert(record);
			if(record.getId() > 0)
				return 1;
			else
				return 0;
		}
		else
			return -1;
	}

}
